<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:ez="http://java.sun.com/jsf/composite/ezcomp"
	xmlns:p="http://primefaces.org/ui"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"
	template="../template/dashLayout.xhtml">
	<ui:param name="title" value="WANDA Social: My Sensor Readings" />
	<ui:define name="dashToolbar">
		<ui:include src="../template/common/commonDashToolbar.xhtml" />
	</ui:define>
	<ui:define name="dashBody">
		<h:form id="tableForm">
			<p:dataTable var="r" id="sensorTable"
				value="#{userSession.subjectDbAdapter.measurements}" width="100%"
				height="100%">
				<f:facet name="noData">
                    No matches found.
                </f:facet>
				<p:column sortBy="#{r.startTimeLong}" sortFunction="#{r.compareReadingTimeLong}">
					<f:facet name="header">
						<h:outputText value="Time of Reading" />
					</f:facet>
					<h:outputText value="#{r.dayString} at #{r.timeString}" />
				</p:column>
				<p:column filterBy="#{r.sensorSpec.id}"
					filterOptions="#{userSession.subjectDbAdapter.sensorIds}"
					filterMatchMode="exact">
					<f:facet name="header">
						<h:outputText value="Filter by Sensor Type:" />
					</f:facet>
					<h:panelGroup>
						<h:outputText value="#{r.sensorSpec.type} (#{r.sensorSpec.id})" />
						<h:graphicImage id="infoIcon" alt="Info icon"
							url="/images/info.png"
							style="vertical-align: center; float: right;" />
						<p:tooltip for="infoIcon" showEffect="fade" hideEffect="fade">
							<h:panelGrid columns="2">
								<h:outputText value="Manufacturer:" style="float:right;" />
								<h:outputText value="#{r.sensorSpec.manufacturer}"
									styleClass="tooltipData" style="float: left;" />
								<h:outputText value="Model:" style="float:right;" />
								<h:outputText value="#{r.sensorSpec.model}"
									styleClass="tooltipData" style="float: left;" />
								<h:outputText value="Specification:" style="float:right;" />
								<h:outputText value="#{r.sensorSpec.spec}"
									styleClass="tooltipData" style="float: left;" />
							</h:panelGrid>
						</p:tooltip>
					</h:panelGroup>
				</p:column>
				<p:column sortBy="#{r.valueDouble}" sortFunction="#{r.compareReadingValueDouble}">
					<f:facet name="header">
						<h:outputText value="Reading Value" />
					</f:facet>
					<h:outputText value="#{r.value}" />
				</p:column>
				<p:column>
					<f:facet name="header">
						<h:outputText value="Units" />
					</f:facet>
					<h:outputText value="#{r.sensorSpec.unit}" />
				</p:column>
				<p:column>
					<f:facet name="header">
						<h:outputText value="Actions" />
					</f:facet>
					<h:panelGroup>
						<h:commandLink
							onclick="postToNewsFeed('New #{userSession.facebookAppAdapter.getValue('name')} sensor reading!', '#{userSession.facebookAppAdapter.getValue('description')}', '#{userSession.facebookUserAdapter.getMeField('first_name')} recorded a reading of #{r.value} #{r.sensorSpec.unit} for #{r.sensorSpec.type} (#{r.sensorSpec.id})!')">
							<h:graphicImage id="instantPublish"
								alt="One-time measurement publish icon"
								url="/images/instantPublish.png"
								style="vertical-align: center;" />
						</h:commandLink>
						<p:tooltip for="instantPublish" showEffect="fade"
							hideEffect="fade">
							<h:outputText value="Post these sensor readings to wall." />
						</p:tooltip>
						<h:graphicImage id="schedulePublish"
							alt="Scheduled measurement publish icon"
							url="/images/schedulePublish.png"
							style="vertical-align: center; position: relative; left: 2px;" />
						<p:tooltip for="schedulePublish" showEffect="fade"
							hideEffect="fade">
							<h:outputText
								value="Schedule automatic posting of this sensor's measurements." />
							<br />
							<h:outputText value="Not yet implemented."
								styleClass="tooltipData" style="float: left;" />
						</p:tooltip>
						<h:commandLink action="dashVisualization.xhtml">
							<f:setPropertyActionListener
								target="#{userSession.wandaVisualization.seriesToChart}"
								value="#{r.sensorId}" />
							<h:graphicImage id="visualizeIcon"
								alt="Visualize sensor readings icon" url="/images/visualize.png"
								style="vertical-align: center; position: relative; left: 15px;" />
						</h:commandLink>
						<p:tooltip for="visualizeIcon" showEffect="fade" hideEffect="fade">
							<h:outputText
								value="Visualize measurements. See a graph of your readings from this and other sensors." />
						</p:tooltip>
					</h:panelGroup>
				</p:column>
			</p:dataTable>
		</h:form>
	</ui:define>
</ui:composition>